import request from '@/utils/request';
import type { AxiosPromise } from '@/utils/request';
import type { PaymentPlanVO, PaymentPlanForm, PaymentPlanQuery } from '@/pagesA/api/workflow/paymentPlan/types';

/**
 * 查询付款计划列表
 * @param query
 * @returns {*}
 */

export const listPaymentPlan = (query?: PaymentPlanQuery): AxiosPromise<PaymentPlanVO[]> => {
  return request({
    url: '/workflow/paymentPlan/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询付款计划详细
 * @param id
 */
export const getPaymentPlan = (id: string | number): AxiosPromise<PaymentPlanVO> => {
  return request({
    url: '/workflow/paymentPlan/' + id,
    method: 'get'
  });
};

/**
 * 新增付款计划
 * @param data
 */
export const addPaymentPlan = (data: PaymentPlanForm) => {
  return request({
    url: '/workflow/paymentPlan',
    method: 'post',
    data: data
  });
};

/**
 * 修改付款计划
 * @param data
 */
export const updatePaymentPlan = (data: PaymentPlanForm) => {
  return request({
    url: '/workflow/paymentPlan',
    method: 'put',
    data: data
  });
};

/**
 * 删除付款计划
 * @param id
 */
export const delPaymentPlan = (id: string | number | Array<string | number>) => {
  return request({
    url: '/workflow/paymentPlan/' + id,
    method: 'delete'
  });
};
